//
//  HandleNetData.m
//  Project
//
//  Created by 冯东辉 on 2018/9/11.
//  Copyright © 2018年 FengDongHui. All rights reserved.
//

#import "HandleNetData.h"

#define NETWORKSTATUSCODEESUCCESS     200
#define NETWORKSTATUSCODENORMALFALSE  999

@implementation HandleNetData

+(NetModel *)successData:(id)json {
    
    NetModel * model = [[NetModel alloc]init];
    
    if( !json) {
        model.statusCode = NETWORKSTATUSCODENORMALFALSE;
        model.isSuccessed = NO;
        return model;
    }
    
    NSInteger code = [[json objectForKey:@"code"] integerValue];
    
    if (code == 1) {
        model.statusCode = NETWORKSTATUSCODEESUCCESS;
        model.isSuccessed = YES;
        model.service = [json objectForKey:@"result"];
    }else {
        model.statusCode = code;
        model.isSuccessed = NO;
    }
    NSLog(@"json : %@", json);
    return model;
}


+(NetModel *)requestFalse {
    
    NetModel * model = [[NetModel alloc]init];
    
    model.statusCode = NETWORKSTATUSCODENORMALFALSE;
    model.isSuccessed = NO;
    model.message = @"网络请求失败";
    return model;
}

@end
